// Learn cc.Class:
//  - https://docs.cocos.com/creator/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        playNode: cc.Node,  //玩家元素
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {

    },

    update (dt) {
        if(!this.playNode) return;

        let w_pos = this.playNode.convertToWorldSpaceAR(cc.v2(0,0));  // 获取玩家所在的世界坐标位置
        let n_pos = this.node.parent.convertToNodeSpaceAR(w_pos);   // 将玩家所在的位置传给摄像机，并返回摄像机的绝对位置
        this.node.position = n_pos;   //设置摄像机的位置;
    },
});
